<template>
	<view>
		<view class="example-body">
			<uni-datetime-picker type="date" v-model="ptime" :clear-icon="false" @maskClick="maskClick" />
		</view>
		<view style="margin: 30rpx;">
			<u-button type="primary" shape="circle" text="点击查询" @click="toSelectTime()"></u-button>
		</view>
		<view v-for="(item,index) in InfoList" :key="index">
			<uni-card title="所选日期打卡时间(默认为今日)" >
				<view style="font-size: 14px;color:#303133;" >
					{{aa(item.ptime)}}
				</view>
			</uni-card>
		</view>
		<view style="margin: 30rpx;">
			<u-button type="primary" shape="circle" text="月度统计" @click="toMonthlyStatistics()"></u-button>
		</view>
		</view>
	</view>


</template>

<script>

		export default {
			data() {
				return {
					user: {time1:'09:01',time2:'18:12'},
					disabled: true,
					InfoList:{

					},
					ptime:''
				}
			},
			onLoad(res) {
				this.toClockInfo()
			},
			methods: {
				aa(date){
								const dateTime = new Date(date)
								const YY = dateTime.getFullYear()
								const MM =
									dateTime.getMonth() + 1 < 10 ? '0' + (dateTime.getMonth() + 1) : dateTime.getMonth() + 1
								const DD =
									dateTime.getDate() < 10 ? '0' + dateTime.getDate() : dateTime.getDate()
								const hh =
									dateTime.getHours() < 10 ? '0' + dateTime.getHours() : dateTime.getHours()
								const mm =
									dateTime.getMinutes() < 10 ? '0' + dateTime.getMinutes() : dateTime.getMinutes()
								const ss =
									dateTime.getSeconds() < 10 ? '0' + dateTime.getSeconds() : dateTime.getSeconds()
								return `${YY}-${MM}-${DD}`
							},
				toMonthlyStatistics(){
					uni.navigateTo({
						url:"./MonthlyStatistics"
					})
				},
				toClockInfo(){
					uni.request({
						url:'http://localhost:9525/performance/punch/select',
						method:'GET',
						success: (res) => {
							this.InfoList=res.data.data.list
						}

					})
				},
				toSelectTime(){
					uni.request({
						url:'http://localhost:9525/performance/punch/getSelectTime?ptime='+this.ptime,
						method:'GET',
						success: (res) => {
							this.InfoList=res.data.data.list
						}

					}),
					console.log(this.time)
				}

			}
		}
</script>

<style>

</style>
